package com.coolbi.onsupai.core.biz.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.coolbi.onsupai.core.biz.AgentBiz;
import com.coolbi.onsupai.core.dao.AgentDao;
import com.coolbi.onsupai.core.entity.Agent;
import com.coolbi.onsupai.core.exception.ServiceException;

public class AgentBizImpl implements AgentBiz{
	@Autowired
	private AgentDao agentDao;
	public void setAgentDao(AgentDao agentDao) {
		this.agentDao = agentDao;
	}

	@Override
	public Agent save(Agent obj) {
		try {
			agentDao.save(obj);
		} catch (Exception e) {
			throw new ServiceException("供应商负责人信息插入发生错误！",e);
		}
		return null;
	}

	@Override
	public void delete(long id) {
		try {
			agentDao.delete(id);
		} catch (Exception e) {
			throw new ServiceException("供应商负责人信息删除发生错误！",e);
		}
	}

	@Override
	public void update(Agent obj) {
		try {
			agentDao.update(obj);
		} catch (Exception e) {
			throw new ServiceException("供应商负责人信息修改发生错误！",e);
		}
	}

	@Override
	public Agent get(long id) {
		return agentDao.get(id);
	}

	@Override
	public List<Agent> list() {
		return agentDao.list();
	}

	@Override
	public List<Agent> listByPage(int offset, int limit) {
		return agentDao.listByPage(offset, limit);
	}

	@Override
	public List<Agent> find(Map<String, Object> parameter) {
		return agentDao.find(parameter);
	}

	@Override
	public List<Agent> findByPage(Map<String, Object> parameter, int offset,
			int limit) {
		return agentDao.findByPage(parameter, offset, limit);
	}

	@Override
	public List<Agent> search(Map<String, Object> parameter, int offset,
			int limit) {
		return agentDao.search(parameter, offset, limit);
	}

	@Override
	public int count() {
		return agentDao.count();
	}

	@Override
	public int countByKeyWord(Map<String, Object> parameter) {
		return agentDao.countByKeyWord(parameter);
	}

	@Override
	public int count(Map<String, Object> parameter) {
		return agentDao.count(parameter);
	}

	@Override
	public boolean checkTel(String tel) {
		return agentDao.countByTel(tel) > 0;
	}

	@Override
	public boolean checkEmail(String email) {
		return agentDao.countByEmail(email) > 0;
	}

	@Override
	public boolean checkAgentName(String agentName) {
		return agentDao.countByAgentName(agentName) > 0;
	}

}
